<form class="create create-registers" action="<?php echo $this->getSetupPostActionUrl() ?>" method="post" id="form-validate">
<div class="page-title">
        <h1><?php echo $this->__('用户注册') ?></h1>
        </div>
<div class="register-first1">
    <div class="account-create account-register">
        <h3><?php echo $this->__('用户信息') ?></h3>
        <?php echo $this->getChildHtml('form_fields_before')?>
        <?php echo $this->getMessagesBlock()->toHtml() ?>
            <div class="">
                <?php echo $this->getBlockHtml('formkey') ?>
                <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
                <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />

                <ul class="form-list">
                    <li>
                        <div class="input-box input-bor input-sp">
                            <input placeholder="<?php echo $this->__('手机号码') ?>" class="phone-res" id="validate-phone" type="text" name="register[mobile]" value="<?php echo $this->escapeHtml($this->getUsername()) ?>"
                                   class="input-text required-entry validate-phoneStrict" />

                            <!-- <input type="button"  class="auth-code" id="vcode-action" value="<?php echo $this->__('发送验证码') ?>"  /> -->
                            <div class="placeholder-text placeholder-iphone"><?php echo $this->__('请输入手机号码') ?></div>
                        </div>
                    </li>
                    <!-- <li>
                        <div class="input-box input-bor input-sp">
                            <input id="validate-id" placeholder="<?php echo $this->__('手机验证码') ?>" type="text" name="register[vcode]"   class="input-text required-entry" />
                            <div class="placeholder-text placeholder-code"><?php echo $this->__('请输入验证码') ?></div>
                        </div>
                    </li> -->
                    <li>
                        <div class="input-box input-bor input-sp">
                            <input id="validate-name" placeholder="<?php echo $this->__('用户名') ?>" type="text" name="register[firstname]"   class="input-text required-entry" />
                            <div class="placeholder-text placeholder-code"><?php echo $this->__('请输入用户名') ?></div>
                        </div>
                    </li>
                    <li>
                        <div class="input-box input-bor input-sp">
                            <input id="validate-nickname" placeholder="<?php echo $this->__('店铺名称') ?>" type="text" name="register[lastname]"   class="input-text required-entry" />
                            <div class="placeholder-text placeholder-code"><?php echo $this->__('请输入店铺名称') ?></div>
                        </div>
                    </li>                                         

                    <li>
                        <div class="input-box input-bor input-sp">
                            <input id="validate-psd" placeholder="<?php echo $this->__('密码') ?>"  type="password" name="register[password]" class="input-text required-entry validate-password" title="<?php echo $this->__('Password') ?>" />
                            <div class="placeholder-text placeholder-psd"><?php echo $this->__('请输入密码') ?></div>
                        </div>
                    </li>
                    <li>
                        <div class="input-box input-bor input-sp">
                            <input id="validate-psd2" placeholder="<?php echo $this->__('确认密码') ?>"  type="password" name="register[confirmation]" class="input-text required-entry validate-password2" title="<?php echo $this->__('Confirm Password') ?>" />
                            <div class="placeholder-text placeholder-psd"><?php echo $this->__('请确认密码') ?></div>
                            <div class="placeholder-text placeholder-psd"><?php echo $this->__('密码不一致') ?></div>
                        </div>
                    </li>

                </ul>
            </div>
    </div>

</div>
<!-- <form action="<?php echo $this->getUrl('complex/account/modifyedcreatePost') ?>" method="post" id="form-validate"> -->
    <div class="register-two">
    <h3><?php echo $this->__('地址填写') ?></h3>
          <div class="buttons-set buttons-registers">
        <div class="address-bor clearfix">
            <div class="address-form clearfix">
            <div class="input-box input-address">
                <?php
                    $provinces = array();
                    $collection = Mage::getModel('directory/region')->getCollection()->addFieldToFilter('country_id', array('eq'=>'CN'));
                    $provinces[] = array('value'=>'','label'=>'-请选择省-');
                    foreach($collection as $region)
                    {
                        $provinces[] = array('value'=>$region->getId(),'label'=>$region->getName());
                    }
                ?>
                <select id="province_id" name="region_id"  class="required-entry">
                    <?php foreach($provinces as $prov):?><option value="<?php echo $prov['value']?>" <?php if($prov['value']==533) echo "selected";?>><?php echo $prov['label']?></option><?php endforeach;?>
                </select>
                <i class="fa fa-angle-right menu-all-block-iRight"></i>
            </div>

            <div class="input-box input-address">
                <?php
                    $collection = Mage::getModel('chinaarea/city')->getCollection()->addFieldToFilter('region_id', array('eq'=>'533'));
                    $citys[] = array('value'=>'','label'=>'-请选择市-');
                    foreach($collection as $city)
                    {
                        $citys[] = array('value'=>$city->getId(),'label'=>$city->getDefaultName());
                    }
                ?>
                <select id="city_id" name="city_id"  class="required-entry">
                    <?php foreach($citys as $city):?><option value="<?php echo $city['value']?>" <?php if($city['value']==160) echo "selected";?>><?php echo $city['label'];?></option><?php endforeach;?>
                </select>
                <i class="fa fa-angle-right menu-all-block-iRight"></i>
            </div>

            <div class="input-box input-address">
                <?php
                $resource = Mage::getSingleton('core/resource');
                $db = $resource->getConnection('core_read');
                $sql = "select `area`.*,website.website_id from directory_country_area `area` right join core_website website on `area`.area_id=website.area_id where `area`.city_id='160'";
                $query = $db->query($sql);
                $collection = $query->fetchAll();
                $websites[] = array('value'=>'','label'=>'-请选择-');
                foreach($collection as $area)
                {
                    $websites[] = array('value'=>$area['website_id'], 'label'=>$area['default_name']);
                }
                ?>

                <select id="website_id" name="website_id" class="required-entry">
                    <?php foreach($websites as $website):?><option value="<?php echo $website['value']?>"><?php echo $website['label'];?></option><?php endforeach;?>
                </select>
                <i class="fa fa-angle-right menu-all-block-iRight"></i>
                <input type="hidden" name="city" id="city" value=""/>
            </div>

            <div class="input-box input-address">
                <input type="text" name="street" class="input-text required-entry" id="validate-address" placeholder="输入详细收货地址"/>
            </div>

            <div class="input-box input-address">
                <input type="text" name="shippingname" class="input-text required-entry" id="shipping-name" placeholder="输入收货人姓名"/>
            </div>

            <div class="input-box input-address">
                <input type="text" name="shippingmobile" class="input-text required-entry" id="shipping-mobile" placeholder="输入收货人电话"/>
            </div>

            </div>
        </div>
    </div>           
    </div>
<!-- </form> -->
<div class="buttons-set buttons-checkout">

    <div class="register-policy">
    <input id="checked-policy" type="checkbox" class="policy-checkbox required-entry"/> <label for="checked-policy"><?php echo $this->__('我已阅读并接受 ') ?></label> <a href="<?php echo $this->getUrl('privacy-policy');?>"><?php echo $this->__('用户注册协议') ?></a>
</div>
<div class="buttons-set buttons-checkout">
    <button id="good-btn" type="submit" title="<?php echo $this->__('Submit') ?>" class="button"><span><span><?php echo $this->__('完成注册') ?></span></span>
        </button> 
</div>
</div>
</form>
<script type="text/javascript">
    //<![CDATA[
    var dataForm = new VarienForm('form-validate', true);
    /*addressInit('cmbProvince', 'cmbCity', 'cmbArea', '湖北', '襄阳市', '襄城区');

    
    new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
    */
    //]]>
    jQuery(document).ready(function(){
        var $ = jQuery;
        if($('#province_id').val()=='') 
        {
            $('#city_id').attr('disabled',true);
            $('#website_id').attr('disabled',true);
        }
        $('.input-address').click(function(){
        $(this).find(".fa").css("display","none");
        });
        $('#province_id').change(function(){
            
            $.getJSON('<?php echo $this->getUrl('zgb/ajax/citys')?>?id='+$(this).val(), function(data){
                $('#city_id').empty();
                $('#website_id').empty();
                var option = $('<option>').val('').text('-请选择-');
                $('#website_id').append(option);
                for(var i=0; i<data.length;i++)
                {
                    var option = $('<option>').val(data[i].value).text(data[i].label);
                    $('#city_id').append(option);
                }
                $('#city_id').attr('disabled',false);
                $('#website_id').attr('disabled',true);
                $('#city_id').find('option:first').attr('selected',true);
            });
        });
        $("#city_id").change(function(){
            $('#website_id').attr('disabled',true);
            $.getJSON('<?php echo $this->getUrl('zgb/ajax/websites')?>?id='+$(this).val(), function(data){
                $('#website_id').empty();
                for(var i=0; i<data.length;i++)
                {
                    var option = $('<option>').val(data[i].value).text(data[i].label);
                    $('#website_id').append(option);
                }
                $('#website_id').attr('disabled',false);
                $('#website_id').find('option:first').attr('selected',true);
            });
        });


        $('#website_id').change(function(){
            var val = $("#website_id").val();
            if(val)
            {
                var city = $("#city_id option:selected").text()+' '+$("#website_id option:selected").text();
                $("#city").val(city);
            }
        });
    });
</script>

